<?php

use Dingo\Api\Routing\Router;

/** @var Router $api */
$api = app(Router::class);

$api->version('v1', ['namespace' => 'App\Http\Controllers'], function ($api) {
    // 不需要验证的接口
    $api->any('login', 'Auth\\AuthController@login'); //登录
    //拉取数据接口
    $api->group(['prefix' => 'pull'], function ($api) {
        $api->any('getProject', 'Pull\\PullController@getProject'); //获取项目列表
        $api->any('getFolder', 'Pull\\PullController@getFolder'); //获取文件夹列表
        $api->any('getArchivesAdmin', 'Pull\\PullController@getArchivesAdmin'); //获取案卷数据
        $api->any('getArchivesFile', 'Pull\\PullController@getArchivesFile'); //获取卷内数据
    });
    //需要登录验证的接口
    $api->group([
        'middleware' => ['api.auth', 'App\\Http\\Middleware\\RequestMiddleware'], //config/api.php 里面的auth
        'limit'      => config('api.rate_limits.access.limit'),
        'expires'    => config('api.rate_limits.access.expires')
    ], function ($api){
        $api->post('logout', 'Auth\\AuthController@logout'); //退出登录
        //部门管理
        $api->group(['prefix' => 'permission'], function ($api) {
            $api->post('add', 'User\\PermissionController@add')->scene('add');//新增部门
            $api->get('deptTree', 'User\\PermissionController@deptTree')->scene('deptTree');//获取部门结构树
            $api->get('getRow', 'User\\PermissionController@getRow')->scene('getRow');//获取部门单条信息
            $api->post('update', 'User\\PermissionController@update')->scene('update');//修改部门
            $api->post('delete', 'User\\PermissionController@delete')->scene('delete');//删除部门
            $api->post('list', 'User\\PermissionController@list')->scene('list');//部门列表
        });
        //用户管理
        $api->group(['prefix' => 'user'], function ($api) {
            $api->post('add', 'User\\UserController@add')->scene('add');//新增用户
            $api->get('getRow', 'User\\UserController@getRow')->scene('getRow');//获取单条数据
            $api->get('getInfo', 'User\\UserController@getInfo')->scene('getInfo');//获取用户信息
            $api->get('getRouters', 'User\\UserController@getRouters')->scene('getRouters');//获取路由地址
            $api->post('update', 'User\\UserController@update')->scene('update');//修改用户
            $api->post('delete', 'User\\UserController@delete')->scene('delete');//删除用户
            $api->post('list', 'User\\UserController@list')->scene('list');//用户列表
        });
        //菜单管理
        $api->group(['prefix' => 'menu'], function ($api) {
            $api->post('add', 'Auth\\MenuController@add')->scene('add');//新增菜单
            $api->get('treeselect', 'Auth\\MenuController@treeselect')->scene('treeselect');//获取菜单结构树
            $api->get('getRow', 'Auth\\MenuController@getRow')->scene('getRow');//获取菜单单条信息
            $api->post('update', 'Auth\\MenuController@update')->scene('update');//修改菜单
            $api->post('delete', 'Auth\\MenuController@delete')->scene('delete');//删除菜单
            $api->post('list', 'Auth\\MenuController@list')->scene('list');//菜单列表
        });
        //角色管理
        $api->group(['prefix' => 'role'], function ($api) {
            $api->post('add', 'User\\RoleController@add')->scene('add');//新增角色
            $api->get('getRow', 'User\\RoleController@getRow')->scene('getRow');//获取角色单条信息
            $api->get('roleMenuTreeselect', 'User\\RoleController@roleMenuTreeselect')->scene('roleMenuTreeselect');//获取角色所选的菜单
            $api->post('update', 'User\\RoleController@update')->scene('update');//修改角色
            $api->post('delete', 'User\\RoleController@delete')->scene('delete');//删除角色
            $api->post('list', 'User\\RoleController@list')->scene('list');//角色列表
        });
        //日志管理
        $api->group(['prefix' => 'log'], function ($api) {
            $api->get('actionLog', 'User\\LogManageController@actionLog')->scene('actionLog');//操作日志
            $api->get('loginLog', 'User\\LogManageController@loginLog')->scene('loginLog');//登录日志
        });
        //档案管理
        $api->get('getProjectList', 'Archives\\ArchivesAdminController@getProjectList');//获取档案目录结构树
        $api->group(['prefix' => 'archives'], function ($api) {
            $api->get('archivesAdmin/getFolederList', 'Archives\\ArchivesAdminController@getFolederList');//获取档案目录结构树
            $api->post('archivesAdmin/getArchivesAdminList', 'Archives\\ArchivesAdminController@getArchivesAdminList');//获取案卷列表数据
            $api->post('archivesAdmin/getArchivesFileList', 'Archives\\ArchivesAdminController@getArchivesFileList');//获取卷内列表数据
            $api->post('archivesAdmin/pullBorrow', 'Archives\\ArchivesAdminController@pullBorrow');//推送借阅
            $api->get('archivesAdmin/borrowList', 'Archives\\ArchivesAdminController@borrowList');//借阅记录
        });
    });
});
